home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d26 / cattest.arc / INTEG3.IN1 < prev    next >
Text File  |  1991-07-01  |  3KB  |  114 lines

  1. PROCEDURE Init_Question;
  2. VAR
  3.   dummy_i {integer, may be deleted}
  4.            {integer variables follow:}
  5.         : Integer;
  6.  
  7.        {real variables follow:}
  8.  dummy_r {real, may be deleted}
  9.   ,R_x
  10.  : Real;
  11.  
  12.        {string variables follow:}
  13.  dummy_s {string, may be deleted}
  14.  ,A_R_x
  15.  : String;
  16.  
  17. BEGIN
  18. {$I-}
  19. Assign (OldQuestionFile,Progname_string+'.SAV');
  20. Reset(OldQuestionFile);
  21. {$I+}
  22. IF IOResult = 0 THEN {this is a repeat, there was a .SAV file}
  23.    BEGIN
  24. ReadLn(OldQuestionFile,R_x);
  25.   Close(OldQuestionFile);
  26.   END
  27.   else  {there was no .SAV file, must generate new values}
  28.   BEGIN
  29.  {question creation section 
  30.            creating new values for student variables}
  31.  
  32. R_x := -0.366;
  33.  ReWrite(OldQuestionFile);{ create the .SAV file just in case
  34.                             student needs to quit and do it again}
  35. WriteLn(OldQuestionFile,R_x);
  36. Close(OldQuestionFile)
  37.   END;
  38.  
  39.  
  40. STR(R_x:4:2,A_R_x);
  41. Trim_fore_aft(A_R_x);
  42.  
  43. question := '';
  44. question2 := '';
  45. question := question + ' The integral from 30 degrees to 60 degrees of sin(x)cos(x)dx is ? ';
  46.  
  47.  
  48. If MaxAvail < Sizeof(Wrong_Answers) then
  49.   BEGIN
  50.     WriteLn('Not enough memory');
  51.     Noise(Bad);
  52.     halt;
  53.   END ELSE
  54.   BEGIN
  55.     New(RootErrorPtr);
  56.     TempPtr := RootErrorPtr;
  57.     TempPtr^.next := nil;
  58.     TempPtr^.value := -2.;
  59.     TempPtr^.remark := 'Did you integrate from pi to zero?';
  60.   END;
  61.  
  62. If MaxAvail < Sizeof(Wrong_Answers) then
  63.   BEGIN
  64.     WriteLn('Not enough memory');
  65.     Noise(Bad);
  66.     halt;
  67.   END ELSE
  68.   BEGIN
  69.     New(GenTempPtr);
  70.     TempPtr^.next := GenTempPtr;
  71.     TempPtr := GenTempPtr;
  72.     TempPtr^.next := nil;
  73.     TempPtr^.value := 2;
  74.     TempPtr^.remark := 'Did you integrate from zero to pi?';
  75.   END;
  76.  
  77. true_answer := R_x;
  78.  
  79. {$IFDEF Watch_Student}
  80.  WriteLn(Outfile,Time_Stamp);
  81.  WriteLn(OutFile,question);
  82.  WriteLn(OutFile,'R_x = ',R_x);
  83.  WriteLn(OutFile,'answer = ',R_x);
  84. {$ENDIF }
  85.  
  86.  
  87. If MaxAvail < Sizeof(Debug_Lines) then
  88.     BEGIN
  89.       WriteLn('Not enough memory');
  90.       Noise(Bad);
  91.       halt;
  92.     END ELSE
  93.     BEGIN
  94.       New(RootDebugLinePtr);
  95.       TempDebugLinePtr := RootDebugLinePtr;
  96.       TempDebugLinePtr^.next := nil;
  97.       TempDebugLinePtr^.line := 'R_x = ' + A_R_x;
  98.     END;
  99.  
  100. If MaxAvail < Sizeof(Debug_Lines) then
  101.     BEGIN
  102.       WriteLn('Not enough memory');
  103.       Noise(Bad);
  104.       halt;
  105.     END ELSE
  106.     BEGIN
  107.       New(GenTempDebugPtr);
  108.       TempDebugLinePtr^.next := GenTempDebugPtr;
  109.       TempDebugLinePtr := GenTempDebugPtr;
  110.       TempDebugLinePtr^.next := nil;
  111.       TempDebugLinePtr^.line := 'R_x = ' + A_R_x;
  112.     END;
  113. END {of .IN1};
  114.